<include file="__THEME__/admin_header" />
<script type="text/javascript">
function checkAll(o)
{
    if( o.checked == true ){
        $('input[name="checkbox"]').attr('checked','true');
        $('tr[overstyle="on"]').addClass("bg_on");
    }else{
        $('input[name="checkbox"]').removeAttr('checked');
        $('tr[overstyle="on"]').removeClass("bg_on");
    }
}

function checkon(o)
{
    if( o.checked == true ){
        $(o).parents('tr').addClass('bg_on') ;
    }else{
        $(o).parents('tr').removeClass('bg_on') ;
    }
}

function getChecked()
{
    var ids = new Array();
    var id;
    $.each($('table input:checked'), function(i, n){
    	id = $(n).val();
        if (id > 0) ids.push(id);
    });
    return ids;
}

// 搜索
var isSearchHidden = <neq name="isSearch" value="1">1<else/>0</neq>;
function searchObject() {
  if(isSearchHidden == 1) {
      $("#searchObject_div").slideDown("fast");
      $(".searchObject_action").html("搜索完毕");
      isSearchHidden = 0;
  }else {
      $("#searchObject_div").slideUp("fast");
      $(".searchObject_action").html("搜索帖子");
      isSearchHidden = 1;
  }
}

var ctrl = function(name){
}
ctrl.prototype = {
		del:function(id, type){
			var id = id ? id : getChecked();
			id = id.toString();
			if(id=='' || id==0){
				alert("请选择要删除的帖子");return false;
			}
		    if (confirm("确认删除帖子？")) {
		        $.post( '__URL__&act=remove',{id:id,type:type},function(text){
		        	if (text == 1) {
		                ui.success("删除多条帖子成功");
		                var id_list = id.split( ',' );   
		                for (var j=0 ; j< id_list.length ; j++) {
		                	$('#list_' + id_list[j]).remove(); 
		                }
		            } else if ( text == 2 ){
		                ui.success( "删除成功" );
		                $('#list_' + id).remove();
		            } else {
		            	ui.error("删除失败");
		            }
		        });
		    }
		}
	}
var c = null;
</script>
<div class="so_main">
	<include file="_tab" />
		<include file="_manage_tab" />

<div id="searchObject_div"<neq name="isSearch" value="1">style="display:none;"</neq>>
<div class="page_tit">搜索帖子 [ <a
	href="javascript:void(0);" onclick="searchObject();">隐藏</a> ]</div>
<div class="form2">
<form method="post"><input
	type="hidden" name="isSearch" value="1" /> <php>if($isSearch !=
'1') $uid = '';</php>
	<dl class="lineD">
		<dt>帖子ID：</dt>
		<dd><input type="text" name="id" class="txt" value="{$id}">
		</dd>
	</dl>
	<dl class="lineD">
		<dt>群组ID：</dt>
		<dd><input type="text" name="gid" class="txt" value="{$gid}" /></dd>
	</dl>
	<dl class="lineD">
		<dt>用户ID：</dt>
		<dd><input type="text" name="uid" class="txt" value="{$uid}" /></dd>
	</dl>
	<dl class="lineD">
		<dt>帖子标题：</dt>
		<dd>
			<input type="text" name="title" class="txt" value="{$title}" />
			<span>支持模糊查询。</span>
		</dd>
	</dl>
	<!-- <dl class="lineD">
		<dt>帖子内容</dt>
		<dd>
			<input type="text" name="content" class="txt" value="{$content}" />
			<span>支持模糊查询。</span>
		</dd>
	</dl> -->
	<dl>
	<dt>结果排序：</dt>
		<dd><select name="field">			
			<option value="addtime"<eq name="field" value="addtime">selected</eq>
			>时间排序</option>
			<option value="id"<eq name="field" value="id">selected</eq>
			>发布id排序</option>
		</select> <select name="order">
			<option value="desc"<eq name="order" value="desc">selected</eq>
			>降序</option>
			<option value="asc"<eq name="order" value="asc">selected</eq>
			>升序</option>
		</select> <select name="limit">
			<option value="10"<eq name="limit" value="10">selected</eq>
			>每页显示10条</option>
			<option value="20"<eq name="limit" value="20">selected</eq>
			>每页显示20条</option>
			<option value="30"<eq name="limit" value="30">selected</eq>
			>每页显示30条</option>
			<option value="100"<eq name="limit" value="100">selected</eq>
			>每页显示100条</option>
		</select>
		</dd>
	</dl>
	<div class="page_btm"><input type="submit" class="btn_b"
	value="确定" /></div>
</form>
</div>
</div>

<div class="Toolbar_inbox">
	<div class="page right">{$list['html']}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchObject();">
	<span class="searchObject_action"><neq name="isSearch" value="1">搜索帖子<else />搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a"
	onclick="c.del(null, 'topic')"><span>删除帖子</span></a>
</div>

<div class="list">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<th style="width: 30px;">
			<input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
			<label for="checkbox"></label>
		</th>
		<th class="line_l">ID</th>
        <th class="line_l">标题</th>
		<th class="line_l">群组</th>
		<th class="line_l">作者</th>
		<th class="line_l">浏览数</th>
		<th class="line_l">回复数</th>
        <th class="line_l">发布时间</th>
        <th class="line_l">操作</th>
	</tr>
	<volist name="list['data']" id='topic'>
	<tr id="list_{$topic.id}">
		<td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$topic.id}"></td>
		<td>{$topic.id}</td>
		<td><a href="{:U('group/Topic/topic',array('gid'=>$topic['gid'],'tid'=>$topic['id']))}" target="_blank">{$topic.title}</a></td>
		<td><a href="{:U('group/Group/index', array('gid'=>$topic['gid']))}" target="_blank">{$_group_names[$topic['gid']]}</a></td>
		<td><space uid="topic.uid" target="_blank">{uname}</space></td>
		<td>{$topic.viewcount}</td>
		<td>{$topic.replycount}</td>
		<td>{$topic.addtime|friendlyDate}</td>
		<td><a href="javascript:void(0)" onclick="c.del({$topic.id}, 'topic')">删除</a></td>
	</tr>
	</volist>
</table>
</div>

<div class="Toolbar_inbox">
	<div class="page right">{$list['html']}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchObject();">
	<span class="searchObject_action"><neq name="isSearch" value="1">搜索帖子<else />搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a"
	onclick="c.del(null, 'topic')"><span>删除帖子</span></a>
</div>
<include file="_footer" />
<script type="text/javascript">
c = new ctrl();
</script>